package com.example.plumneedle.Framgment;

import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.plumneedle.Daka.Daka;
import com.example.plumneedle.PanelView.Questionnaire;
import com.example.plumneedle.PanelView.setup;
import com.example.plumneedle.R;
import com.example.plumneedle.XiaXu.FallObject;
import com.example.plumneedle.XiaXu.Falling;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;

import java.net.URI;

import static android.content.ContentValues.TAG;


public class BlankFragment5 extends Fragment {
    private ImageView imageView;
    private ImageView imageView1;
 //   private ImageView imageView2;
    private Falling fallingView;
    private ConstraintLayout constraintLayout;
    private ConstraintLayout constraintLayout1;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_blank5, container, false);
    }

    public void onActivityCreated(@Nullable Bundle saveInstanceState){
        super.onActivityCreated(saveInstanceState);
        imageView=getActivity().findViewById(R.id.imageView35);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(), setup.class);
                startActivity(intent);
            }
        });
        imageView1=getActivity().findViewById(R.id.imageView3);
        imageView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(), Daka.class);
                startActivity(intent);
            }
        });
        FallObject.Builder builder = new FallObject.Builder(getResources().getDrawable(R.drawable.ic_snow));
        FallObject fallObject = builder
                .setSpeed(7,true)
                .setSize(60,60,true)
                .setWind(5,true,true)
                .build();

        fallingView = getActivity().findViewById(R.id.falling);
        fallingView.addFallObject(fallObject,100);//添加50个下落物体对象
        constraintLayout=getActivity().findViewById(R.id.con4);
        constraintLayout1=getActivity().findViewById(R.id.con_help);
        constraintLayout1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),Questionnaire.class);
                startActivity(intent);
            }
        });
        constraintLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showSimpleBottomSheetGrid();
            }
        });
        /*Intent intent=getActivity().getIntent();
        Boolean cut=intent.getBooleanExtra("cut",false);
        Uri uri=intent.getData();
        String path=intent.getStringExtra("path");*/
    }
    private void showSimpleBottomSheetGrid() {
        final int TAG_SHARE_WECHAT_FRIEND = 0;
        final int TAG_SHARE_WECHAT_MOMENT = 1;
        final int TAG_SHARE_WEIBO = 2;
        final int TAG_SHARE_CHAT = 3;
        final int TAG_SHARE_LOCAL = 4;
        QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(getContext());
        builder.addItem(R.mipmap.a1, "分享到微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
                .addItem(R.mipmap.a2, "分享到朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
                .addItem(R.mipmap.a3, "分享到微博", TAG_SHARE_WEIBO, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
                .addItem(R.mipmap.a4, "分享到私信", TAG_SHARE_CHAT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
                .addItem(R.mipmap.a5, "保存到本地", TAG_SHARE_LOCAL, QMUIBottomSheet.BottomGridSheetBuilder.SECOND_LINE)
                .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
                    @Override
                    public void onClick(QMUIBottomSheet dialog, View itemView) {
                        dialog.dismiss();
                        int tag = (int) itemView.getTag();
                        switch (tag) {
                            case TAG_SHARE_WECHAT_FRIEND:
                                Toast.makeText(getContext(), "分享到微信", Toast.LENGTH_SHORT).show();
                                break;
                            case TAG_SHARE_WECHAT_MOMENT:
                                Toast.makeText(getContext(), "分享到朋友圈", Toast.LENGTH_SHORT).show();
                                break;
                            case TAG_SHARE_WEIBO:
                                Toast.makeText(getContext(), "分享到微博", Toast.LENGTH_SHORT).show();
                                break;
                            case TAG_SHARE_CHAT:
                                Toast.makeText(getContext(), "分享到私信", Toast.LENGTH_SHORT).show();
                                break;
                            case TAG_SHARE_LOCAL:
                                Toast.makeText(getContext(), "保存到本地", Toast.LENGTH_SHORT).show();
                                break;
                        }
                    }
                }).build().show(); }

}
